/**
 * @file functions.h
 * @brief The function for all the questions
 * @author XDDDD
 * @version 
 * @date 2021-06-10
 */

#ifndef __PAISLEYPARK__FUNCTIONS_H__
#define __PAISLEYPARK__FUNCTIONS_H__

#include "VectorFunction.h"
#include <cmath>

class f_1 : public VectorFunction<1> {
public:
	double operator()(const std::vector<double>& _p) const {
		double re = 0;
		double x = _p[0];
		re = -cos(x)*cos(x)*exp(sin(x)) + sin(x)*exp(sin(x));
		return re; 
	};
};

class f_2 : public VectorFunction<1> {
public:
	double operator()(const std::vector<double>& _p) const {
		double re = -2;
		return re;
	};
};

class f_3 : public VectorFunction<2> {
public: 
	double operator()(const std::vector<double>& _p) const  {
		double re = 0;
		double x = _p[0];
		double y = _p[1];
		re += -cos(x)*cos(x)*exp(sin(x)*sin(y)) + sin(x)*exp(sin(x)*sin(y));
		re += -cos(y)*cos(y)*exp(sin(x)*sin(y)) + sin(y)*exp(sin(x)*sin(y));
		return re;
	};
};

class f_4 : public VectorFunction<2> {
public:
	double operator()(const std::vector<double> &_p) const {
		double re = 0;
		double x = _p[0];
		double y = _p[1];
		re += -2*(y*y - y);
		re += -2*(x*x - x);
		return re;
	};
};

class g_1 : public VectorFunction<1> {
public:
	double operator()(const std::vector<double>& _p) const {
		double re = 0;
		double x = _p[0];
		re = exp(sin(x));
		return re;
	};		
};

class g_2 : public VectorFunction<1> {
public:
	double operator()(const std::vector<double>& _p) const {
		double re = 0;
		double x = _p[0];
		re = x*x - x;
		return re;
	};	
};

class g_3 : public VectorFunction<2> {
public:
	double operator()(const std::vector<double>& _p) const {
		double re = 0;
		double x = _p[0];
		double y = _p[1];
		re = exp(sin(x)*sin(y));
		return re;
	};
};

class g_4 : public VectorFunction<2> {
public:
	double operator()(const std::vector<double>& _p) const {
		double re = 0;
		double x = _p[0];
		double y = _p[1];
		re = (x*x - x)*(y*y - y);
		return re + 1;
	};	
};

#else
//Do nothing.
#endif
